#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
int T,gg;
struct r{
	int d,v,a;
}c[maxn];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while(T--){
		int n,m,L,V,cnt=0;
		cin>>n>>m>>L>>V;
		int rd[L+5];
		memset(rd,0,sizeof(rd));
		for(int i=1;i<=n;i++)cin>>c[i].d>>c[i].v>>c[i].a;
		for(int i=1;i<=m;i++){int s;cin>>s;rd[s]=1;gg=s;}
		if(c[1].a==0){
		//	for(int i=L;i;i--)rd[i]+=rd[i+1];
			for(int i=1;i<=n;i++)if(c[i].d<=gg&&c[i].v>V)cnt++;
			cout<<cnt<<' ';
			if(cnt>0)cout<<m-1;
			else cout<<m;
			cout<<'\n';
		}else{
			for(int i=1;i<=n;i++){
				if(c[i].d>gg)continue;
				double gg2=gg-c[i].d;
				gg2*=2*c[i].a;gg2+=c[i].v*c[i].v;
				double vs=sqrt(gg2);
				if(vs>V)cnt++;
			}
			cout<<cnt<<' ';
			if(cnt>0)cout<<m-1;
			else cout<<m;
			cout<<'\n';
		}
	}
	return 0;
}
